New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@shopify/i18n

Package Overview
Dependencies
Maintainers
24
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shopify/i18n

Generic i18n-related utilities

  • 2.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
28K
decreased by-33.21%
Maintainers
24
Weekly downloads
 
Created
Source

@shopify/i18n

Build Status Build Status License: MIT npm version npm bundle size (minified + gzip)

Generic i18n-related utilities.

Installation

yarn add @shopify/i18n

Usage

pseudotranslate()

Takes a string and returns a version of it that appears as if it were translated (learn more about pseudotranslation).

This function accepts a number of arguments to customize the translation:

  • toLocale: a locale to simulate translation for. This is used primarily to adjust the change in size relative to the original string. When not provided, or when a locale is provided for which no custom size ratio exists, this function slightly increases the string size.
  • delimiter, startDelimiter, endDelimiter: strings used to mark parts of the source string that should not be translated. This can be used, for example, to prevent translation of replacements within a string.
  • prepend and append: strings to put at the start and end of the resulting string, respectively. This can be used to provide a common set of text around pseudotranslated code that can identify translated strings that are incorrectly joined together.
import {pseudotranslate} from '@shopify/react-i18n';

const pseudoOne = pseudoTranslate('cat'); // something like 'ͼααṭ'
const pseudoTwo = pseudoTranslate('cats: {names}', {
  toLocale: 'de',
  startDelimiter: '{',
  endDelimiter: '}',
  prepend: '[[!',
  append: '!]]',
}); // something like '[[!ͼααṭṡṡ: {names}]]!'

regionFromLocale()

Accepts a locale and extracts the country code as defined in BCP 47, if it exists. The country code will be normalized to fully uppercase when present.

import {regionFromLocale} from '@shopify/i18n';

const regionEn = regionFromLocale('en'); // undefined
const regionEnCa = regionFromLocale('en-ca'); // 'CA'

languageFromLocale()

Accepts a locale and extracts the language subtag as defined in BCP 47.

import {languageFromLocale} from '@shopify/i18n';

const languageFrCa = languageFromLocale('fr-CA'); // 'fr'

FAQs

Package last updated on 10 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc